Skip to main content

All Questions

Tagged with
6votes
3answers
465views

Leetcode: Largest Number

I was trying out leetcode's Largest Number. As per the challenge's description: Given a list of non-negative integers nums, arrange them such that they form the largest number and return it. Since ...
ccot's user avatar
  • 361
1vote
3answers
142views

Maximum Sum BST in a Binary Tree

I was trying to find the Maximum sum BST of a binary tree on LeetCode. While the Java code I have come up with, mostly seems right and is able to pass 55 out of the given 59 test cases too, the error ...
Siddharth Garg's user avatar
2votes
1answer
94views

Semi-dynamic range minimum query (RMQ) tree in Java

Introduction I have this semi-dynamic range minimum query (RMQ) tree in Java. It is called semi-dynamic due to the fact that it cannot be modified after it is constructed. However, the values ...
coderodde's user avatar
3votes
2answers
401views

Implementation of a market that matches bids to offers

This is my task: Each line in the file can be one of the following: Updates to the limit order book in the following format: ...
Данил Денк's user avatar
2votes
1answer
757views

Traverse a list of tree nodes

I am wondering if there is a better way to traverse a list of trees. Here is my current algorithm: Collect the parent IDs in a Map Traverse all the groups and find ones where their ID is not in the ...
Mr. Polywhirl's user avatar
1vote
1answer
87views

Java - Select the maximum integers from sliding windows over an array

So I have the following algorithm. Given an array A[0 ... n - 1] and the window length w, compute all the windows ...
coderodde's user avatar
3votes
0answers
345views

Simple Merkle Tree

Discussion I just started learning about Merkle Trees and wanted to get some practice by attempting to implement a very simple Merkle Tree. The constructor for the tree takes some type of hash ...
Jae Bradley's user avatar
1vote
1answer
67views

Comparing two general LCA algorithms in Java

Now I have two algorithms solving a problem: given a general (multi-way) tree, and any array of node names, find the the node that is the deepest common ancestor. ...
coderodde's user avatar
1vote
1answer
217views

Comparing a prefix tree against a HashSet of strings in Java

Here, I have made an attempt to find out whether a prefix tree is any more efficient than a simple java.util.HashSet<String>. See what I have: ...
coderodde's user avatar
0votes
1answer
56views

is my Prim's MST implementation terse enough?

I did research because I want to learn Kruskal's and Prim's MSTs. I did research and after a solid understanding, I went to my textbook and got their libraries: https://algs4.cs.princeton.edu/code/...
William Golovlev's user avatar
3votes
1answer
109views

Building a tree containing all permutations of arithmetic expressions given some numbers

Given any series of numbers, for example 1,2,3,4,5 and given the arithmetic operands + - * / including parenthesis, what would be the most optimal way to build a tree that contains all permutations ...
Mihael Keehl's user avatar
2votes
1answer
107views

Pretty print a tree from minimal data input

I'm currently working on an uncrafting tool for minecraft and got a neat output working that shows all the materials needed in a tree. I wonder if the code used to print that tree could be improved ...
mindoverflow's user avatar
2votes
1answer
106views

Find Invalid User Relationships in User to Manager Map (validate map as valid tree structure with no circular relationships)

We have a new service where an admin can upload a spreadsheet of new users they want to add to our application. During our processing we make a union map of all the users both existing and new ...
Kevin Vandy's user avatar
2votes
1answer
373views

Sum of all Paths in Binary Tree

Problem For the given binary tree return the list which has sum of every paths in a tree. i.e Every path from root to leaf. I've written following solution. ...
Ashish Pawar's user avatar
1vote
1answer
118views

Data mining in Java: finding undrawn lottery rows - follow-up

(See the previous (initial) iteration.) This time, I have substantially reduced the usage of the final and this keywords. Also, ...
coderodde's user avatar

153050per page
close